﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProductKMListing.ascx.cs" Inherits="Controls_ProductKMListing" %>
<%@ Import Namespace="BLL" %>

 <table>                           
 <tr>
    <td valign="middle">
       <b><small>Số sản phẩm hiển thị trên mỗi trang:</small></b>
    </td>
    <td valign="middle">
        <asp:RadioButtonList runat="server" ID="rblPageIndex"  AutoPostBack="true" RepeatDirection="Horizontal" onselectedindexchanged="rblPageIndex_SelectedIndexChanged">
               <asp:ListItem Value="5">5</asp:ListItem>
               <asp:ListItem Value="10" Selected="True">10</asp:ListItem>
               <asp:ListItem Value="25">25</asp:ListItem>
               <asp:ListItem Value="50">50</asp:ListItem>   
               <asp:ListItem Value="100">100</asp:ListItem>
        </asp:RadioButtonList>
    </td>
 </tr>
</table>    
<p></p>

<asp:Button ID="btn_themmoi" runat="server" Text="Thêm mới" 
        onclick="btn_themmoi_Click" /> 
<p></p>
<asp:GridView runat="server" ID="gvwProducts" DataKeyNames="ID" Width="100%"
    DataSourceID="objAllProducts" AllowPaging="true" AutoGenerateColumns="False" onrowcreated="gvwProducts_RowCreated">
        <Columns>
                <asp:TemplateField HeaderText="STT">
                    <ItemTemplate>
                        <asp:Literal runat="server" ID="lblSTT" Text='<%#Container.DataItemIndex + 1 %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:ImageField  HeaderText="Hình" DataImageUrlField="SmallImageUrl" 
                    ItemStyle-Width="110px" >
                <ItemStyle Width="110px"></ItemStyle>
                </asp:ImageField>
                
                <asp:HyperLinkField HeaderText="Tên" SortExpression="Title" HeaderStyle-HorizontalAlign="Left"
                    DataTextField="Title" 
                    DataNavigateUrlFormatString="~/ShowProduct.aspx?ID={0}" 
                    DataNavigateUrlFields="ID" >
                    
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                </asp:HyperLinkField>
                    
                <asp:TemplateField HeaderText="Loại" SortExpression="DepartmentID">
                    <ItemTemplate>
                        <asp:Literal runat="server" ID="lblDepartment" Text='<%#Eval("Department.Title") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                    
                <asp:TemplateField HeaderText="Mã" SortExpression="CodeProduct">
                    <ItemTemplate>
                        <asp:Literal runat="server" ID="lblCodeProduct" Text='<%#Eval("CodeProduct") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
      
            <asp:TemplateField HeaderText="Edit" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20px">
                    <ItemTemplate>
                        <asp:HyperLink runat="server" ID="lnkEdit" ToolTip="Edit product"
                            NavigateUrl='<%# "~/Admin/AddEditProduct.aspx?ID=" + Eval("ID") %>' ImageUrl="~/Images/Edit.gif" />
                    </ItemTemplate>         

<ItemStyle HorizontalAlign="Center" Width="20px"></ItemStyle>
           </asp:TemplateField>
           
            <asp:CommandField ButtonType="Image" HeaderText="Delete" DeleteImageUrl="~/Images/Delete.gif" DeleteText="Delete" ShowDeleteButton="True">
                <ItemStyle HorizontalAlign="Center" Width="20px" />
            </asp:CommandField>
        </Columns>
</asp:GridView>

<asp:ObjectDataSource ID="objAllProducts" runat="server" DeleteMethod="DeleteProduct" SelectMethod="ListProductsKM" TypeName="BLL.Store.Product">
   <DeleteParameters>
      <asp:Parameter Name="id" Type="Int32" />
   </DeleteParameters>
</asp:ObjectDataSource>